//manhattan go from top-left to bottom-right
//list all possible way
//m:#rows
//n:#columns


#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

//recursive version
void manhattan_go(int m, int n, string s)
{
  static int count = 0;
  if(m==0&&n==0){//basis, arrive at goal
    count++;
    cout<<count<<"\t"<<s<<endl;
    return;
  }else if( m == 0) {//on the boundary   
    manhattan_go(m,n-1,s+'R');
    return;
  }else if( n == 0) {//on the boundary 
    manhattan_go(m-1,n,s+'D');
    return;
  }else { 
    manhattan_go(m,n-1,s+'R');  
    manhattan_go(m-1,n,s+'D');
    return;
  }
}

//iterative version: how to make m as a variable??
void iter(int n)//m = 3
{
  int count = 0;
  for(int i = 0;i < n+1;i++)
    for(int j = i+1; j< n+2; j++)
      for(int k = j+1; k< n+3; k++){
	string s(3+n,'R');
	s[i]=s[j]=s[k]='D';
	count++;
	cout<<count<<"\t"<<s<<endl;
      }
  return;
}

int main(int argc,char *argv[])
{
  int m,n;
  if(argc == 3){
    m = atoi(argv[1]);
    n = atoi(argv[2]);
  }
  else{
    m = 3;
    n = 4;
  }
  string s = "";
  manhattan_go(m,n,s);
//   iter(4);
  return 0;
}
